<?php
namespace Client\Controller;
use Think\Controller;
use Org\Net\Http;
class RecommendController extends Controller {
    public function refreshRecommend(){
    	S('recommend_list',null);
    	$this->showRecommend();
    }
    public function showRecommend() {
    	$list = S('recommend_list');
    	$pageSize = 10;
    	$page = I('page');
    	if(isset($page)){
    		$start = $page*$pageSize;
    	}
    	if(!$list){
	   		$recommend = D('Recommend');
	   		$list = $recommend->cache('recommend_list')->order('id desc')->select();
    	}
	   	$res = array_slice($list,$start,$pageSize);
	   	if(count($res)>0){
	   		$json['result'] = 0;
	   		$json['msg'] = "成功";
	   		$json['recommend'] = $res;
	   	}else{
	   		$json['result'] = -1;
	   		$json['msg'] = "暂无推荐";
	   	}
	   	$this->ajaxReturn($json);
    }
}